<?php
// $Id$
/**
 * @file
 * Responsible for functions related to the forms of the website.
 */

/**
 * Function that build the 'Block Form'.
 */
function baseproject_custom_form($form_state) {
  $form['login'] = array(
    '#id' => 'login',
    '#type' => 'textfield',
    '#title' => 'Login',
    '#size' => '30',
    '#required' => TRUE,
  );
  $form['pass'] = array(
    '#id' => 'pass',
    '#type' => 'password',
    '#title' => 'Password',
    '#maxlength' => 8,
    '#size' => '30',
  );

  $form['submit'] = array(
    '#id' => 'submit',
    '#type' => 'submit',
    '#value' => 'Send',
  );

  $form['#redirect'] = FALSE;
  $form['#theme'] = 'login';
  $form['#validate'][] = 'baseproject_custom_form_validate';
  $form['#submit'][] = 'baseproject_custom_form_submit';

  return $form;
}

function baseproject_custom_form_validate($form, &$form_state) {
  $login = $form_state['values']['login'];
  $pass = $form_state['values']['pass'];

  if ($pass === '')  {
    form_set_error('login', 'CustomValidation: Please fill Password field correctly.');
  }
}

function baseproject_custom_form_submit($form, &$form_state) {
  $login = $form_state['values']['login'];
  $pass = $form_state['values']['pass'];

  drupal_goto('<front>');
}